<?php



namespace app\mobile\model;



use think\Model;

use think\Session;



class InfoModel extends Model

{

    protected $table = 'tp_info';



    public function getTypeNameAttr()

    {

        $typeInfo = TypeModel::get($this->typeId);

        return !empty($typeInfo) ? $typeInfo->typeName : '';

    }



    public function getList($typeId, $num = 7)

    {

        return self::where(['state' => 1, 'typeId' => $typeId])

            ->order('sort asc')

            ->limit($num)

            ->select();

    }



    public function getInfo($typeId)

    {

        return self::where([ 'state' => 1, 'typeId' => $typeId])

            ->order('sort asc')

            ->find();

    }



    public function getOne($condition)

    {

        return self::where(['state' => 1])

            ->where($condition)

            ->order('sort asc')

            ->find();

    }

}